Closed loop anesthesia